SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO





CREATE VIEW [dbo].[SSB_CUSIP_Map] AS




SELECT DISTINCT  i.extid AS FS_ID, ssr.CUSIP AS SSB_ID

 FROM  FSFundModel.dbo.StateStreetRecon ssr


INNER JOIN  FSFundModel.Reporting.AssetIdentifier ai
ON ai.AssetId = ssr.StateStreetIdentifier
INNER JOIN FSFundModel.Reporting.Instrument i ON
ai.InstrumentId = i.InstrumentId
AND ai.ExportId = i.ExportId
INNER JOIN  FSFundModel.Reporting.Asset a ON
ai.InstrumentId = a.InstrumentId
AND ai.PortfolioId  = a.PortfolioId
AND ai.LotId = a.LotId
AND ai.ExportId = a.ExportId 

WHERE ai.ExportId =(SELECT MAX(e.ExportId) FROM FSFundModel.Reporting.Export e WHERE e.FundId ='FSIC' AND e.NAVDate < '10/1/2013')

AND a.IsActiveEndOfDay = 1





GO
